<?php

namespace Mageplaza\HelloWorld\Plugin;

class ExamplePlugin{
    /*前置插件在Settitle 方法运行之前执行该方法*/
    /*public function beforeSetTitle(\Mageplaza\HelloWorld\Controller\Index\Example $subject, $title)
    {

        if($title=="Welcome"){
            $title = '这个是前置方法修改的信息11111';
        }
        $title = $title . " to ";
        //echo __METHOD__ . "</br>";

        return [$title];
    }*/
    /* 后置插件在方法后置之后执行该方法*/
    /*public function  afterSetTitle(\Mageplaza\HelloWorld\Controller\Index\Example $subject, $title){
        $title ="<h1>这个是后置方法信息</h1>";
        return $title;
    }*/

    public function aroundGetTitle(\Mageplaza\HelloWorld\Controller\Index\Example $subject, callable $proceed)
    {

        echo "<pre>";
        echo __METHOD__ . " - Before proceed() </br>";
        $result = $proceed();
        echo __METHOD__ . " - After proceed() </br>";


        return $result;
    }

    public function aroundTest(\Mageplaza\HelloWorld\Controller\Index\Example $subject, callable $proceed){

        echo "xx333";
        $result = $proceed();
        return $result;
    }
    public function aroundName(\Mageplaza\HelloWorld\Controller\Index\Example $subject, callable $proceed,...$args){
        return $proceed($args);
    }

}
